package com.ysx.server.mapper;

import cn.hutool.db.sql.Order;
import com.github.pagehelper.Page;
import com.ysx.server.pojo.dto.OrderPageQueryDTO;
import com.ysx.server.pojo.dto.OrderStatusDTO;
import com.ysx.server.pojo.dto.OrderVO;
import com.ysx.server.pojo.entity.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface OrderMapper {
    /**
     * 获取所有订单信息
     * @return
     */
    @Select("select * from second_hand_trading.orders where orderStatus= 1")
    List<Orders> getAll();

    /**
     * 保存订单
     * @param aliPay
     */
    void save(OrderVO aliPay);
    /**
     * 订单动态查询
     * @param orderPageQueryDTO
     * @return
     */
    Page<Orders> page(OrderPageQueryDTO orderPageQueryDTO);

    /**
     * 根据用户id获取订单信息
     * @param userId
     * @return
     */
    @Select("select * from second_hand_trading.orders where userId = #{userId}")
    List<Orders> getUserOrder(Long userId);

    @Select("select * from second_hand_trading.orders where sellId = #{userId}")
    List<Orders> getSellOrder(Long userId);

    /**
     * 根据订单id获取订单信息
     * @param id
     * @return
     */
    @Select("select * from second_hand_trading.orders where id = #{id}")
    Orders getOrderDetail(Long id);

    /**
     * 更新订单状态
     * @param orderStatusDTO
     * @return
     */
    @Update("update second_hand_trading.orders set orderStatus = #{status} where id = #{id}")
    boolean updateStatus(OrderStatusDTO orderStatusDTO);
}
